Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: disallow follower reads for writing transactions #35969

Merged

Conversation

nvanbenschoten
Copy link
Member

Fixes #35812.

To avoid missing its own writes, a transaction must not evaluate a read
on a follower who has nit caught up to at least its current provisional
commit timestamp. We were violating this both at the DistSender level and
at the Replica level.

Because the ability to perform follower reads in a writing transaction is
fairly unimportant and has these known issues, this commit disallows
follower reads for writing transactions.

Release note: None

@nvanbenschoten nvanbenschoten requested review from ajwerner and a team March 19, 2019 23:59
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/storage/closed_timestamp_test.go, line 303 at r1 (raw file):

	var notLeaseholderErrs int64
	for i := range repls {
		repl := repls[i]

This is copied from code below but can we drop the func(r *storage)? r isn't used and there's no reason to both define and use repl and pass repls[i] to a function.

I guess I got burned by the captured iterator variable too many times?


pkg/storage/closed_timestamp_test.go, line 511 at r1 (raw file):

	for i := range repls {
		repl := repls[i]
		func(r *storage.Replica) {

Can you drop the func here while you're around? It's even more egregious here because r gets shadowed by the retry

Fixes cockroachdb#35812.

To avoid missing its own writes, a transaction must not evaluate a read
on a follower who has nit caught up to at least its current provisional
commit timestamp. We were violating this both at the DistSender level and
at the Replica level.

Because the ability to perform follower reads in a writing transaction is
fairly unimportant and has these known issues, this commit disallows
follower reads for writing transactions.

Release note: None
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/noTxnFollowerRead branch from 733561f to 93a4113 Compare March 21, 2019 00:22
Copy link
Member Author

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner)


pkg/storage/closed_timestamp_test.go, line 303 at r1 (raw file):

Previously, ajwerner wrote…

This is copied from code below but can we drop the func(r *storage)? r isn't used and there's no reason to both define and use repl and pass repls[i] to a function.

I guess I got burned by the captured iterator variable too many times?

Done.


pkg/storage/closed_timestamp_test.go, line 511 at r1 (raw file):

Previously, ajwerner wrote…

Can you drop the func here while you're around? It's even more egregious here because r gets shadowed by the retry

Done.

craig bot pushed a commit that referenced this pull request Mar 21, 2019
35969: kv: disallow follower reads for writing transactions r=nvanbenschoten a=nvanbenschoten

Fixes #35812.

To avoid missing its own writes, a transaction must not evaluate a read
on a follower who has nit caught up to at least its current provisional
commit timestamp. We were violating this both at the DistSender level and
at the Replica level.

Because the ability to perform follower reads in a writing transaction is
fairly unimportant and has these known issues, this commit disallows
follower reads for writing transactions.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
@craig
Copy link
Contributor

craig bot commented Mar 21, 2019

Build succeeded

@craig craig bot merged commit 93a4113 into cockroachdb:master Mar 21, 2019
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/noTxnFollowerRead branch March 25, 2019 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants